package com.aspose.cells;

import java.util.ArrayList;

class zaec {
   private zaeh a = null;
   private String b;
   private int c;
   private HtmlSaveOptions d;

   zaec(Workbook var1, com.aspose.cells.b.a.d.zm var2, String var3, HtmlSaveOptions var4) throws Exception {
      this.c = var4.getSaveFormat();
      this.d = var4;
      WorksheetCollection var5 = var1.getWorksheets();
      var5.o();
      var5.p();
      this.a = new zaeh(var1, (String)null, var3, var2, var4);
   }

   zaec(Workbook var1, com.aspose.cells.b.a.d.zm var2, HtmlSaveOptions var3) throws Exception {
      this.c = var3.getSaveFormat();
      this.d = var3;
      WorksheetCollection var4 = var1.getWorksheets();
      var4.o();
      var4.p();
      String var5 = var1.getFileName();
      String var6 = null;
      if (var5 != null && !"".equals(var5)) {
         var6 = com.aspose.cells.b.a.d.zk.e(var5) + com.aspose.cells.b.a.d.zk.a + com.aspose.cells.b.a.d.zk.c(var5) + ".mht";
      } else {
         var6 = "c://main.mht";
      }

      this.a = new zaeh(var1, var6, (String)null, var2, var3);
   }

   zaec(Workbook var1, String var2, String var3, HtmlSaveOptions var4) throws Exception {
      this.c = var4.getSaveFormat();
      this.d = var4;
      this.b = var2;
      WorksheetCollection var5 = var1.getWorksheets();
      var5.o();
      var5.p();
      this.a = new zaeh(var1, var2, var3, (com.aspose.cells.b.a.d.zm)null, var4);
   }

   void a() throws Exception {
      com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh();
      Encoding var2 = this.a.c().getEncoding();
      if (var2 == null) {
         var2 = Encoding.getUTF8();
      }

      zaml var3 = null;
      zafg var4 = null;
      String var5 = null;
      String var6 = null;
      String var7 = null;
      String var8 = null;
      String var9 = null;
      String var10 = null;
      ArrayList var11 = null;
      String var12 = null;
      String var13 = com.aspose.cells.b.a.d.zk.c(this.b);
      String var14;
      if (var13 == null || "".equals(var13)) {
         var14 = this.a.j().getFileName();
         if (var14 != null && !"".equals(var14)) {
            var13 = com.aspose.cells.b.a.d.zk.c(this.a.j().getFileName());
         } else {
            var13 = "main";
         }
      }

      if (this.c == 17) {
         var5 = "----=_NextPart_aspose01.20120615";
         var6 = "file:///C:/aspose01/";
         var7 = "quoted-printable";
         var8 = "base64";
         var9 = "text/html; charset=\"" + Encoding.getUTF8().b() + "\"";
         var10 = "image/png";
         var11 = new ArrayList();
         var3 = new zaml(var1, var2);
         var4 = var3.a(var5);
         var4.a(17);
         var4.a(Encoding.getUTF8());
         var5 = "--" + var5;
      }

      if ((this.a.n != null && !this.a.c().getExportImagesAsBase64() || this.a.c().getExportImagesAsBase64()) && this.a.c().getExportObjectListener() == null) {
         zadw var20 = new zadw(this.a);
         var20.a(var4, var5, var6 + var13 + "_files/", var8, var10, false);
      }

      zadx var21;
      if (this.c == 17) {
         var21 = new zadx(this.a, var6, this.d);
         var12 = var13 + ".htm";
         var21.a(var4, var5, var6 + var12, var7, var9, this.d);
         if (var11 != null) {
            com.aspose.cells.b.a.a.ze.a(var11, (Object)var12);
            var6 = var6 + var13 + "_files/";
         }

         if ((this.a.n != null && !this.a.c().getExportImagesAsBase64() || this.a.c().getExportImagesAsBase64()) && this.a.c().getExportObjectListener() == null) {
            zadw var15 = new zadw(this.a);
            var15.a(var4, var5, var6, var8, var10, true);
         }
      }

      com.aspose.cells.b.a.a.zc var28;
      zadu var30;
      if (this.a.r.size() <= 1) {
         if (this.c != 17) {
            var21 = new zadx(this.a, var6, this.d);
            var12 = var13 + ".htm";
            var21.a(var4, var5, var6 + var12, var7, var9, this.d);
            if (var11 != null) {
               com.aspose.cells.b.a.a.ze.a(var11, (Object)var12);
               var6 = var6 + var13 + "_files/";
            }
         }

         if (var4 != null && var4.b().size() > 0) {
            var28 = com.aspose.cells.b.a.a.zf.a(var4.b());

            while(var28.c()) {
               zaeh.b(var4, var5, (String)var28.a(), var8, var10);
               var4.a(com.aspose.cells.b.a.ze.a((byte[])((byte[])var28.b())));
            }
         }

         if (var3 != null) {
            var30 = new zadu(this.a);
            var12 = "filelist.xml";
            var30.a(var4, var5, var6 + var12, var7, var9);
            if (var11 != null) {
               com.aspose.cells.b.a.a.ze.a(var11, (Object)var12);
            }

            var3.a(var5, false);
            var1.b(0L);
            var3.a((String)this.b, (com.aspose.cells.b.a.d.zm)var1, (Encoding)Encoding.getUTF8(), (String)var5);
         }

      } else {
         for(int var22 = 0; var22 < this.a.r.size(); ++var22) {
            zaeb var23 = new zaeb(this.a, var22, var6, this.d);
            String var16 = var23.a(var4, var5, var6, var7, var9, this.d);
            if (var11 != null) {
               com.aspose.cells.b.a.a.ze.a(var11, (Object)var16);
            }
         }

         if (this.a.r.size() > 1) {
            var14 = null;

            try {
               var12 = "stylesheet.css";
               StreamProviderOptions var24 = new StreamProviderOptions();
               zafg var25 = this.a.b(var4, var5, var6 + var12, var7, var9, var24);
               zady var27 = new zady(this.a);
               var27.a(var25);
               if (var11 != null) {
                  com.aspose.cells.b.a.a.ze.a(var11, (Object)var12);
               }

               this.a.u.closeStream(var24);
            } finally {
               ;
            }

            zaea var26 = new zaea(this.a);
            var12 = "tabstrip.htm";
            var26.a(var4, var5, var6 + var12, var7, var9);
            if (var11 != null) {
               com.aspose.cells.b.a.a.ze.a(var11, (Object)var12);
            }
         }

         if (var4 != null && var4.b().size() > 0) {
            var28 = com.aspose.cells.b.a.a.zf.a(var4.b());

            while(var28.c()) {
               zaeh.b(var4, var5, (String)var28.a(), var8, var10);
               var4.a(com.aspose.cells.b.a.ze.a((byte[])((byte[])var28.b())));
            }
         }

         var30 = new zadu(this.a);
         var12 = "filelist.xml";
         var30.a(var4, var5, var6 + var12, var7, var9);
         if (var11 != null) {
            com.aspose.cells.b.a.a.ze.a(var11, (Object)var12);
         }

         if (this.c != 17) {
            zadx var29 = new zadx(this.a, var6, this.d);
            var12 = var13 + ".htm";
            var29.a(var4, var5, var6 + var12, var7, var9, this.d);
            if (var11 != null) {
               com.aspose.cells.b.a.a.ze.a(var11, (Object)var12);
               var6 = var6 + var13 + "_files/";
            }
         }

         if (var3 != null) {
            var3.a(var5, false);
            var1.b(0L);
            var3.a((String)this.b, (com.aspose.cells.b.a.d.zm)var1, (Encoding)Encoding.getUTF8(), (String)var5);
         }

      }
   }

   void a(com.aspose.cells.b.a.d.zm var1) throws Exception {
      com.aspose.cells.b.a.d.zh var2 = new com.aspose.cells.b.a.d.zh();
      Encoding var3 = this.a.c().getEncoding();
      if (var3 == null) {
         var3 = Encoding.getUTF8();
      }

      zaml var4 = null;
      zafg var5 = null;
      String var6 = null;
      String var7 = null;
      String var8 = null;
      String var9 = null;
      String var10 = null;
      String var11 = null;
      ArrayList var12 = null;
      String var13 = null;
      String var14 = com.aspose.cells.b.a.d.zk.c(this.b);
      if (var14 == null || "".equals(var14)) {
         String var15 = this.a.j().getFileName();
         if (var15 != null && !"".equals(var15)) {
            var14 = com.aspose.cells.b.a.d.zk.c(this.a.j().getFileName());
         } else {
            var14 = "main";
         }
      }

      if (this.c == 17) {
         var6 = "----=_NextPart_aspose01.20120615";
         var7 = "file:///C:/aspose01/";
         var8 = "quoted-printable";
         var9 = "base64";
         var10 = "text/html; charset=\"" + Encoding.getUTF8().b() + "\"";
         var11 = "image/png";
         var12 = new ArrayList();
         var4 = new zaml(var2, var3);
         var5 = var4.a(var6);
         var5.a(17);
         var5.a(Encoding.getUTF8());
         var6 = "--" + var6;
      }

      if (this.a.n != null && this.a.c().getExportObjectListener() == null) {
         zadw var22 = new zadw(this.a);
         var22.a(var5, var6, var7 + var14 + "_files/", var9, var11, false);
      }

      zadx var23 = new zadx(this.a, var7, this.d);
      var13 = var14 + ".htm";
      var23.a(var5, var6, var7 + var13, var8, var10, this.d);
      if (var12 != null) {
         com.aspose.cells.b.a.a.ze.a(var12, (Object)var13);
         var7 = var7 + var14 + "_files/";
      }

      if (var5 != null && this.a.n != null && this.a.c().getExportObjectListener() == null) {
         zadw var16 = new zadw(this.a);
         var16.a(var5, var6, var7, var9, var11, true);
      }

      com.aspose.cells.b.a.a.zc var28;
      zadu var30;
      if (this.a.r.size() <= 1) {
         if (var5 != null && var5.b().size() > 0) {
            var28 = com.aspose.cells.b.a.a.zf.a(var5.b());

            while(var28.c()) {
               zaeh.b(var5, var6, (String)var28.a(), var9, var11);
               var5.a(com.aspose.cells.b.a.ze.a((byte[])((byte[])var28.b())));
            }
         }

         if (var4 != null) {
            var30 = new zadu(this.a);
            var13 = "filelist.xml";
            var30.a(var5, var6, var7 + var13, var8, var10);
            if (var12 != null) {
               com.aspose.cells.b.a.a.ze.a(var12, (Object)var13);
            }

            var4.a(var6, false);
            var2.b(0L);
            var4.a((com.aspose.cells.b.a.d.zm)var1, (com.aspose.cells.b.a.d.zm)var2, (Encoding)Encoding.getUTF8(), (String)var6);
         }

      } else {
         for(int var24 = 0; var24 < this.a.r.size(); ++var24) {
            zaeb var17 = new zaeb(this.a, var24, var7, this.d);
            String var18 = var17.a(var5, var6, var7, var8, var10, this.d);
            if (var12 != null) {
               com.aspose.cells.b.a.a.ze.a(var12, (Object)var18);
            }
         }

         if (this.a.r.size() > 1) {
            zafg var25 = null;

            try {
               var13 = "stylesheet.css";
               StreamProviderOptions var26 = new StreamProviderOptions();
               var25 = this.a.b(var5, var6, var7 + var13, var8, var10, var26);
               zady var29 = new zady(this.a);
               var29.a(var25);
               if (var12 != null) {
                  com.aspose.cells.b.a.a.ze.a(var12, (Object)var13);
               }

               this.a.u.closeStream(var26);
            } finally {
               if (var25 != null && var5 == null) {
                  ;
               }

            }

            zaea var27 = new zaea(this.a);
            var13 = "tabstrip.htm";
            var27.a(var5, var6, var7 + var13, var8, var10);
            if (var12 != null) {
               com.aspose.cells.b.a.a.ze.a(var12, (Object)var13);
            }
         }

         if (var5 != null && var5.b().size() > 0) {
            var28 = com.aspose.cells.b.a.a.zf.a(var5.b());

            while(var28.c()) {
               zaeh.b(var5, var6, (String)var28.a(), var9, var11);
               var5.a(com.aspose.cells.b.a.ze.a((byte[])((byte[])var28.b())));
            }
         }

         var30 = new zadu(this.a);
         var13 = "filelist.xml";
         var30.a(var5, var6, var7 + var13, var8, var10);
         if (var12 != null) {
            com.aspose.cells.b.a.a.ze.a(var12, (Object)var13);
         }

         if (var4 != null) {
            var4.a(var6, false);
            var2.b(0L);
            var4.a((com.aspose.cells.b.a.d.zm)var1, (com.aspose.cells.b.a.d.zm)var2, (Encoding)Encoding.getUTF8(), (String)var6);
         }

      }
   }
}
